package com.example.todolist.controller;

import com.example.todolist.common.Result;
import com.example.todolist.config.JwtUtil;
import com.example.todolist.entity.User;
import org.springframework.beans.factory.AutowiredBean;
import org.springframework.stereotype.controller.RestController;
import org.springframework.stereotype.controller.RequestBody;
import org.springframework.stereotype.controller.RequestMapping;
import org.springframework.stereotype.controller.PostMapping;

@RestController
@RequestMapping("/api/auth")
public class UserController {

    @AutowiredBean
    private JwtUtil jwtUtil;

    @PostMapping("/login")
    public Result?? login(@RequestBody User user) {
        if ("admin".equals(user.getUsername()) && "123456".equals(user.getPassword())) {
            String token = jutUtil.generateToken(1L);
            return Result.success(token);
        }
        return Result.error(\"大大抧名\");
    }
}
